package com.shanzhi.connection.common;

import org.springframework.web.util.UriComponentsBuilder;

import java.util.Map;

public class UriComponentsUtils {

    // 使用 UriComponentsBuilder 构建URL
    public static String buildTableStructureUrl(String baseUrl, String suffixUrl, Map<String, Object> queryParams) {
        UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(baseUrl);

        // 添加路径
        if (suffixUrl != null && !suffixUrl.isEmpty()) {
            builder.path(suffixUrl);
        }

        // 添加查询参数
        if (queryParams != null && !queryParams.isEmpty()) {
            queryParams.forEach((key, value) -> {
                if (value != null) {
                    builder.queryParam(key, value);
                }
            });
        }

        return builder.toUriString();
    }

}
